﻿#pragma once

#include <vector>
#include <map>

class PressKeyUtil
{
public:
	PressKeyUtil();
	~PressKeyUtil();
	static PressKeyUtil& inst();

	bool SendKeyByKeyIndex(int key_index);
	// key 
	void SendKey(unsigned char key);

	void SendKey(std::vector<unsigned char>& keys, int key_index);

	void WriteActionList(int key_index, DWORD use_time);

	void SendKeyBySpellID(int spell_id);
	//
	void FindKeyBySpellID(int spell_id);

	void StartLock()
	{
		ready_Lock = true;
	}

	void EndLock()
	{
		ready_Lock = false;
		send_lock = false;
	}

	bool SendLock()
	{
		return send_lock;
	}
public:
	bool press_battle_enbale = true;
private:
	DWORD time_last_press = 0;

	bool ready_Lock = false;
	bool send_lock = false;
	int  last_key_index = 0;
	DWORD last_action_tick = 0;
	void Init();

	using map_front_keys = std::map<int, unsigned char>;

	map_front_keys map_front_key_ = {
	{10, '0'},
	{11, VK_OEM_MINUS},
	{12, VK_OEM_PLUS},
	};

	map_front_keys map_number_key_ = {
	{10, VK_NUMPAD0},
	{11, VK_SUBTRACT},
	{12, VK_ADD},
	};

	using press_keys = std::vector<unsigned char>;
	using map_action_keys = std::map<int, press_keys>;
	map_action_keys map_action_keys_;
};

